package com.qk.management.service.serviceimpl;

import cn.hutool.core.bean.BeanUtil;
import com.qk.common.constant.CacheConstants;
import com.qk.domain.HomeOverviewDO;
import com.qk.domain.business.BusinessHomeDO;
import com.qk.domain.clue.ClueHomeDO;
import com.qk.management.aop.anno.Cacheable;
import com.qk.management.mapper.BusinessMapper;
import com.qk.management.mapper.ClueMapper;
import com.qk.management.service.HomeOverviewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.concurrent.TimeUnit;

/**
 * @author 上官徵羽
 */
@Service
public class HomeOverviewServiceImpl implements HomeOverviewService {
    @Autowired
    private ClueMapper clueMapper;
    @Autowired
    private BusinessMapper businessMapper;

    @Cacheable(
            KeyPrefix = CacheConstants.CACHE_PORTAL_KEY_PREFIX,
            expireTime = 24*60L,
            expireTimeUnit = TimeUnit.MINUTES
    )
    @Override
    public HomeOverviewDO getList() {
        ClueHomeDO clueHomeDO = clueMapper.selectCountClue();
        BusinessHomeDO businessHomeDO = businessMapper.selectCountBusiness();
        HomeOverviewDO vo = BeanUtil.copyProperties(clueHomeDO, HomeOverviewDO.class);
        BeanUtil.copyProperties(businessHomeDO, vo);
        return vo;
    }

}
